<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>我的订单</title>
    <script src="__INDEX__/js/mui.min.js"></script>
    <link href="__INDEX__/css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
    <link rel="stylesheet" href="__INDEX__/css/style.css" />
    <link rel="stylesheet" href="__INDEX__/css/yund.css" />
</head>

<body>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">订单</h1>
	</header>		
	<div class="mui-content">
		<ul class="myord_nav clearfix">
	    	<li {if !$status}class="active"{/if}><a href="{:url('member/orders')}">全部</a></li>
	    	<li {if $status==1}class="active"{/if}><a href="{:url('member/orders',['status'=>1])}">待付款</a></li>
	    	<li {if $status==2}class="active"{/if}><a href="{:url('member/orders',['status'=>2])}">待发货</a></li>
	    	<li {if $status==3}class="active"{/if}><a href="{:url('member/orders',['status'=>3])}">待收货</a></li>
	    	<li {if $status==4}class="active"{/if}><a href="{:url('member/orders',['status'=>4])}">待评价</a></li>
	    </ul>
		<div class="order_listbox">
			{volist name='order_list' id='order_info' empty="没有数据"}
			<div class="order_item">
				<div class="order_zt clearfix" style="padding:1%">
					<div class="left"><span class="iconfont icon-shangcheng"></span>{$order_info['agent_name']}</div>
					<div class="right">
						{:get_order_type($order_info['status'])}
					</div>
				</div>
				<div class="order_zt clearfix" style="padding:0px">
					<div class="left" style="width: 100%;">订单编号：{$order_info['order_sn']}</div>
				</div>
				<ul class="order_item_list">
					{volist name="$order_info.order_item" id="order_item"}
					<li>
						<div class="order_item_spimg"><img src="{$order_item['thumb']}" style="min-height: 6.5rem;min-width: 6.5rem;"></div>
						<div class="order_item_spinfo">
							<div class="order_itspnam">{$order_item['goods_name']}</div>
							<div class="order_isp_b clearfix">
								<span class="ord_pribox">
									<em class="pri">¥{$order_item['price']}</em>
									<em class="yj">¥{$order_item['sale_price']}</em>
								</span>
								<span class="pay_spnum">X{$order_item['nums']}</span>
							</div>
							<div class="order_isp_b clearfix">
								{if $order_info.status===4}
								<div class="order_item_btnbox clearfix" style="padding: 0px;border-top:0px">
									<a href="{:url('shop/order_comment',['order_id'=>$order_info['id'],'goods_id'=>$order_item['goods_id']])}" >评价</a>
								</div>
								{/if}
							</div>
						</div>
					</li>
					{/volist}
				</ul>
				<div class="order_item_zj">
					<span>共{:count($order_info.order_item)}件商品</span>
					<span class="jiag">合计：<em>¥{$order_info.total_price}</em></span>
					<!--<span class="yunf">(含运费¥0.00)</span>-->
				</div>
				{if $order_info.status===1}
				<div class="order_item_btnbox clearfix">
					<a href="javascript:void(0)" onclick="cancel_pay('{$order_info.id}')">取消订单</a>
					<a href="{:url('shop/buy',['order_id'=>$order_info.id])}" class="order_fkbtn">付款</a>							
				</div>
				{/if}
				{if $order_info.status===3}
				<div class="order_item_btnbox clearfix">
					<a href="javascript:void(0)" onclick="take_order('{$order_info.id}')">确认收货</a>
				</div>
				{/if}
			</div>
			{/volist}
		</div>

	</div>
</body>
</html>
{include file="public/footer" /}
<script>
	function cancel_pay(id){
		layer.confirm('您确定取消订单？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type:"post",
				url: "{:url('shop/cancel_order')}",
				data: {order_id : id},//表单数据
				success: function(data) {
					layer.msg(data.msg, {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						  if(data.code == 200) {
								location.reload();
						  }
					}); 
				}
			})
		})
	}
	
	
	function take_order(id){
		layer.confirm('您确定收货？', {
			btn: ['确定', '取消'] //按钮
		}, function() {
			$.ajax({
				type:"post",
				url: "{:url('shop/take_order')}",
				data: {order_id : id},//表单数据
				success: function(data) {
					layer.msg(data.msg, {
					  icon: 1,
					  time: 1500 //2秒关闭（如果不配置，默认是3秒）
					}, function(){
						  if(data.code == 200) {
								location.reload();
						  }
					}); 
				}
			})
		})
	}
	
</script>
